#ifndef OCTREE_H
#define OCTREE_H

#include "Node.h"
#include "frustum.h"
#include <list>

class Octree
{
public:
	Octree(int levels, float width, float height, float depth);
	~Octree(void);

	Node* getRoot() { return root; }
	std::list<Entity*>* getEntities() { return entities; }
	std::list<Collider*>* getColliders() { return colliders; }
	float getWidth() { return m_width; }
	float getHeight() { return m_height; }
	float getDepth() { return m_depth; }
	
	void addEntity(Entity* ent) { entities->push_back(ent); }
	void addCollider(Collider* coll) { colliders->push_back(coll); }
	void addTerrainClump(TerrainClump* clump) { clumps->push_back(clump); }
	void removeEntity(Entity* ent) { entities->remove(ent); }
	void removeCollider(Collider* coll) { colliders->remove(coll); }

	void scopeEntities(); //puts entities into their correct node
	void scopeEntity(Entity* ent);
	void scopeTerrain();

	void render(int mode, Frustum& frustum);
private:
	Node* root;
	
	//number of levels in the tree
	int m_levels;

	//width, height and depth of root node
	float m_width;
	float m_height;
	float m_depth;

	std::list<Entity*>* entities; //contains all entities in the trees
	std::list<TerrainClump*>* clumps;
	std::list<Collider*>* colliders;
};

#endif

